package com.liu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {

    //原来的风格：http://localhost:8080/SpirngMVC_044_controller_war_exploded/add?a=1&b=2
    //Restful： ：http://localhost:8080/SpirngMVC_044_controller_war_exploded/a/b

//    @RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)
    @PostMapping ("/add/{a}/{b}")
    public  String  Test1(@PathVariable int a,@PathVariable String b, Model model){
        String result=a+b;
        model.addAttribute("msg","结果1为"+result);
        return "test";
    }

    @GetMapping ("/add/{a}/{b}")
    public  String  Test2(@PathVariable int a,@PathVariable String b, Model model){
        String result=a+b;
        model.addAttribute("msg","结果2为"+result);
        return "test";
    }
}
